/*
*作者---杨彬
*
*/
<template>
    <div>
      <empty-content :text="sData.emptyContent" v-if='isEmpty' class="emptyBox"></empty-content>
      <cake-nav :navData="sData.couponSData.navText" v-show='isForShow'></cake-nav>
      <couponItem class="coupon-item-content" :allItemData='allItemData'  v-if="allItemData&&allItemData.length>0" :imgBg="$route.params.id">

      </couponItem>
    </div>
</template>
<script type="text/javascript">
  import cakeNav from 'src/components/com/nav/nav.vue'
  import couponItem from 'src/components/couponItem/couponItem.vue'
  import emptyContent from "src/components/com/emptyContent/emptyContent.vue";
  export default {
    data(){
      return{
        isForShow:true,
        thisIsCoupon:true,
        allItemData:'',
        UrlHeader:'',
        isEmpty:false
      }
    },
    props:["sData"],
    components:{cakeNav,couponItem,emptyContent},
    methods:{
      getNewData(ocouponstatus,ocunponType){
        this.allItemData="";
        var  willSendData={userId:this.sData.userId,
          status:ocouponstatus?ocouponstatus:'',
        }
        if(this.$route.params.forPage=='true'){
            var pA=m$.localStrages.get('prodId');
            var rr='';
            var psuhArry=[];
            for(var i=0;i<pA.length;i++){
              if(psuhArry.indexOf (pA[i])==-1){
                psuhArry.push(pA[i]);
                rr+=pA[i]+','
              }

            };
            rr=rr.substring(0,rr.length-1);
          willSendData['productIds[]']=rr;
        }
        this.isEmpty = false;
        this.getAjax(this.sData.url.coupon,willSendData,(res)=>{
          console.log(res);
          if(res && res.status==200){
              if(res.data.length!=0){
                this.allItemData = res.data;
              }else {
                  this.isEmpty=true;
              }
          }
        })
      }
    },
    watch:{
      '$route':function (val) {
        this.getNewData(val.params.id)
      }
    },
   created(){
      
     document.title=this.sData.couponSData.title;
     this.UrlHeader=(this.$route.fullPath).substring(0,(this.$route.fullPath).length-2);
     let thisUrlArr=this.sData.couponSData.navText;
     for(var i=0;i<thisUrlArr.length;i++){
       thisUrlArr[i].url=this.UrlHeader+'/'+i
     }
     if(this.$route.params.forPage == 'true'){
      this.isForShow = false;
      this.allItemData = this.$route.params.coupons;
     }else{
      console.log('00000000');
      this.isForShow = true;
      this.getNewData(this.$route.params.id)
     }
   }
}
</script>
<style scoped lang="less">
@import "coupon";
</style>
